//package com.wangc.commons.interceptor;
//
//import com.wangc.commons.interceptor.handler.UserTaskHandler;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.*;
//import javax.servlet.annotation.WebFilter;
//import javax.servlet.http.HttpServletRequest;
//import java.io.IOException;
//import java.util.regex.Pattern;
//
///**
// * @program: do-yx-core
// * @ClassName:UserFilter
// * @description: 处理用户相关的过滤器
// * @author: GYB
// * @create: 2020-05-13 17:28
// **/
//@Component
//@WebFilter(urlPatterns = {"/**"}, filterName = "userFilter")
//@Slf4j
//public class UserFilter implements Filter {
//
//    UserTaskHandler userTaskHandler;
//
//    @Autowired
//    public UserFilter(UserTaskHandler userTaskHandler) {
//        this.userTaskHandler = userTaskHandler;
//    }
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//
//        String contextPath = ((HttpServletRequest) servletRequest).getContextPath();
//
//        log.info("--[get user time consuming]-- start to get user info,context-path:{} ", contextPath);
//        long startTime = System.currentTimeMillis();
//
//        //正则匹配应用服务
//        boolean checkBsContext = Pattern.matches("/bs-yx-(.*)", contextPath);
//
//        if (checkBsContext) {
//            //处理用户消息
//            userTaskHandler.getUserFromRedisCache((HttpServletRequest) servletRequest);
//        }else {
//            //如果是领域层服务，直接从head获取用户
//            userTaskHandler.getUserFromHead((HttpServletRequest) servletRequest);
//        }
//
//        log.info("--[get user time consuming]-- end to get user info,waste time {} ms", System.currentTimeMillis() - startTime);
//        filterChain.doFilter(servletRequest, servletResponse);
//    }
//}
